import { parseTime } from '../utils'

export default {
  data() {
    const now = new Date() // 当前日期
    const nowDayOfWeek = now.getDay() // 今天本周的第几天
    const nowDay = now.getDate() // 当前日
    const nowMonth = now.getMonth() + 1 // 当前月
    let nowYear = now.getYear() // 当前年
    nowYear += (nowYear < 2000) ? 1900 : 0 //
    const lastTwoMonthDate = new Date() // 上月日期
    lastTwoMonthDate.setDate(1)
    lastTwoMonthDate.setMonth(lastTwoMonthDate.getMonth() - 2)
    const lastHalfYearDate = new Date() // 上月日期
    lastHalfYearDate.setDate(1)
    lastHalfYearDate.setMonth(lastHalfYearDate.getMonth() - 6)
    console.log(lastTwoMonthDate, lastHalfYearDate)
    return {

      week: {
        start_time: '',
        End_time: ''
      },
      two_month: {
        start_time: '',
        End_time: ''
      },
      half_year: {
        start_time: '',
        End_time: ''
      }
    }
  },
  methods: {
    getWeekDate() {
      var weekStartDate = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek)
      var weekEndDate = new Date(nowYear, nowMonth, nowDay + (6 - nowDayOfWeek))
      this.week = {
        start_time: parseTime(weekStartDate),
        End_time: parseTime(weekEndDate)
      }
    }
  }
}
